package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import datas.GraphInfos;

public class GraphSaver extends JFrame {	
	private JTextField name_field = new JTextField("graph name");
	private JTextField creator_field = new JTextField("creator name");
	private JTextArea desc_field = new JTextArea("short description");
	private JButton validate = new JButton("Send!");
	
	private JPanel pan = new JPanel();
	
	private MainWindow parent;
	
	public GraphSaver(MainWindow _p) {
		this.parent = _p;
		
		this.pan.add(this.name_field);
		this.pan.add(this.creator_field);
		this.pan.add(this.desc_field);
		this.pan.add(this.validate);
		
		this.add(this.pan);
		
		
		this.validate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				GraphInfos ret = new GraphInfos(GraphSaver.this.name_field.getText(),
												GraphSaver.this.creator_field.getText(),
												GraphSaver.this.desc_field.getText());
				
				GraphSaver.this.parent.saveGraph(ret);
				GraphSaver.this.dispose();		
			}			
		});
		
		this.show(true);
		this.pack();
		this.setVisible(true);
	}
	
	
}
